<?php

namespace App\Repository\Repositories;

use App\Repository\Repositories\Interfaces\ItemsCrontabsRepository;
use App\Repository\Models\ItemsCrontabs;

/**
 * Class ItemsCrontabsRepositoryEloquent.
 *
 * @package namespace App\Repository\Repositories;
 */
class ItemsCrontabsRepositoryEloquent extends BaseRepository implements ItemsCrontabsRepository
{
    /**
     * 搜索
     * @var array
     */
    protected $table='items_crontabs';
    protected $fieldSearchable = [''];



    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return ItemsCrontabs::class;
    }

    //关闭配单
    public function affirmDone($order_id)
    {
        $ret = $this->query()
            ->where(['order_id' => $order_id, 'type' => ItemsCrontabs::TYPE_CANCEL, 'status' => ItemsCrontabs::STATUS_NONE])
            ->update(['status' => ItemsCrontabs::STATUS_DONE]);
        return $ret ? true : false;
    }
}
